﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HA.ModFlow.Domain.DomainLayer;

using HA.Data;

using HA.ModFlow.Infrastructure;


namespace HA.ModFlow.Application
{
   public  class RCHMFViewModel:MDTVIViewModel
    {

       public RCHMFViewModel(MDTVIViewModel parent,RechargeCollection rechargeCollecion)
           : base(parent, false)


       {

           this._rechargeCollecion = rechargeCollecion;

           this._contextMenu = new System.Windows.Controls.ContextMenu();



           this.LoadChildren();
 

       }



       RechargeCollection _rechargeCollecion;


       public override string Desc
       {
           get
           {
               return "补给";
           }
       }


       protected override void LoadChildren()
       {
           base.LoadChildren();


          List<RechargePeriod> rates=  this._rechargeCollecion.Recharge.Periods;



          List<CellCenterDataSet3d> lstDs = new List<CellCenterDataSet3d>();

           int nrow=this._rechargeCollecion.Nrows;

           int ncol=this._rechargeCollecion.Ncols;

           List<int[,]> ibound = ProjectService.DefaultService.Project.MfData.GridData.WaterGrid.GetIBounds();
          

          foreach (RechargePeriod item in rates)
          {
              //这里的数据只有一级

              double[,,] temp=new double[nrow,ncol,1];

              for (int i = 0; i < nrow; i++)
              {
                  for (int j = 0; j < ncol; j++)
                  {

                      temp[i, j, 1] = item.Flux[i, j];
                      
                  }
                  
              }

              CellCenterDataSet3d ds = new CellCenterDataSet3d(temp,ibound);
              
              lstDs.Add(ds);



          }

          DSGrid3d dsRate = new DSGrid3d("RCHRate",lstDs);

          DSGrid3dViewModel vm = new DSGrid3dViewModel(this,dsRate);

          this.Children.Add(vm);



       }

       protected override void OnSelectedChanged()
       {
           if (this.IsSelected)
           {

               UIModule.DefaultModule.RibbonV2ViewModel.ViewOpViewModel.ToolVM.CurrentTool = APPTOOLMODE.GRID3D;

           }
       }

    }
}
